<?php
/* @var $this MemTypeController */
/* @var $model MemType */
/* @var $form CActiveForm */
?>
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'mem-type-form',
	'enableAjaxValidation'=>false,
	'enableClientValidation'=>true,
	'htmlOptions'=>array('enctype'=>'multipart/form-data','class'=>'create_role set_authority'),
)); ?>

<ul class="form_list form_list2">
	<li><h3><?php echo $model->isNewRecord?"创建":"编辑"?>会员等级</h3></li>
	<li class="c_f">
		<span class="tit">等级名称：</span>
		<div class="cont f_l">
		<?php echo $form->textField($model,'zmt_title',array('size'=>60,'maxlength'=>100)); ?>
		<?php echo $form->error($model,'zmt_title'); ?>
		</div>
	</li>

<?php if(F::siteType() !=2){ //如果是单店铺，会员组为1 ?>
	<li class="c_f">
		<span class="tit">会员组：</span>
		<div class="cont f_l">
		<?php echo $form->dropDownlist($model,'zmg_id',MemGroup::model()->getMemGroup()); ?>
		<?php echo $form->error($model,'zmg_id'); ?>		
		</div>
	</li>
<?php }else{?> 
		<?php echo CHtml::hiddenField('MemType[zmg_id]','1')?>
<?php }?>


	<li class="c_f">
		<span class="tit">会员等级标志：</span>
		<div class="cont f_l">
			<div class="c_img50">
			    <img id="img1" src="<?php if(!empty($model->zmt_pic)){echo $model->zmt_pic;}else{echo "/images/pro_img.jpg";}?>" alt="" />
			</div>
			<p class="mt10">
			    <?php echo CHtml::link('上传图片<b class="mem_bgx left"></b><b class="mem_bgx right"></b>'.CHtml::fileField('image','',array('id'=>'uploadimg1','multiple'=>true)),'javascript:',array('class'=>'mem_bgx link_btn filelink mr20','onclick'=>"uploadimg('1')"))?>
			    <?php echo $form->hiddenField($model,'zmt_pic',array('id'=>'proimage1'))?>  
			</p>  
			<script src="<?php echo Yii::app()->baseUrl;?>/js/upload_img.js"></script>
		</div>
	</li>
	
	<li class="c_f">
		<span class="tit">状态：</span>
		<div class="cont f_l">
		<?php echo $form->radioButtonList($model,'zmt_stat',array('1'=>'不显示','2'=>'显示'),array('class'=>'radio','labelOptions'=>array('class'=>'mr20'))); ?>
		<?php echo $form->error($model,'zmt_stat'); ?>
		</div>
	</li>
	
	<li class="c_f">
		<span class="tit">最小条件：</span>
		<div class="cont f_l">
		<?php echo $form->textField($model,'zmt_min'); ?>
		<?php echo $form->error($model,'zmt_min'); ?>
		</div>
	</li>

	<li class="c_f">
		<span class="tit">最大条件：</span>
		<div class="cont f_l">
		<?php echo $form->textField($model,'zmt_max'); ?>
		<?php echo $form->error($model,'zmt_max'); ?>
		</div>
	</li>
	
	<li class="c_f">
		<span class="tit">等级描述：</span>
		<div class="cont f_l">
		<?php echo $form->textArea($model,'zmt_content',array('cols'=>80,'rows'=>5)); ?>
		<?php echo $form->error($model,'zmt_content'); ?>
		</div>
	</li>
	
	<li class="c_f">
		<span class="tit">会员等级权限：</span>
		<div class="cont f_l">
			<ul id="privilege1" class="main_list d_n">
				<?php  $tasks = MemGroup::model()->getCmpTask();?>
				<?php 	foreach($tasks as $key=>$val){ ?>
				<li class="item">
						<?php echo CHtml::label($val,'') ?>
						<?php echo CHtml::checkBoxList("privilege[$key][]",isset($actions)?$actions:'',MemGroup::model()->getTaskAction($key),array('checkAll'=>'all','container'=>'ul','separator'=>'','template'=>'<li>{input} {label}</li>','containerClass'=>'subsub_list c_f'));?>
				</li>
				<?php }?>	
			</ul>
			<ul id="privilege2" class="main_list ">
				<?php  $tasks = MemGroup::model()->getMemTask();?>
				<?php 	foreach($tasks as $key=>$val){ ?>
				<li class="item">
						<?php echo CHtml::label($val,'') ?>
						<?php echo CHtml::checkBoxList("privilege[$key][]",isset($actions)?$actions:'',MemGroup::model()->getTaskAction($key),array('checkAll'=>'全选','container'=>'ul','separator'=>'','template'=>'<li>{input} {label}</li>','containerClass'=>'subsub_list c_f'));?>
				</li>
				<?php }?>	
			</ul>
		</div>
	</li>

	<li class="c_f"><span class="tit">&nbsp;</span>
		<div class="cont f_l">
			<?php echo CHtml::submitButton(Yii::t('adm','Save Date'),array('class'=>'mem_btn mem_btn20 mr5')); ?>
		</div>
	</li>
</ul>
<?php $this->endWidget(); ?>
<script type="text/javascript">
$('#MemType_zmg_id').bind('change',function(){
	var select = $('#MemType_zmg_id option:selected').val();
	if(select==3){
		$('#privilege2').fadeOut("slow");
		$('#privilege2').find('input').attr('checked' ,false);
		$('#privilege1').fadeIn("slow");
	}else if(select==1){
		$('#privilege1').fadeOut("slow");
		$('#privilege1').find('input').attr('checked' ,false);
		$('#privilege2').fadeIn("slow");
	}
});
$(function(){
	$('.subsub_list').each(function(){
			//alert($(this).find('li').length);
			$(this).find('li').first().addClass("check_all");
	 });
});

</script>